<template>
  <div class="mb-10px">
      <SvgIcon
        class="mt-5px ml-5px cursor-pointer"
        :name="svgName"
        :color="iconColor"
        :width="size"
        :height="size"
        @click="handleClick"
      />
      <p class="ml--10px text-15px text-center mt--2px mb-10px">返回顶部</p>
  </div>
</template>

<script setup lang="ts">
import { useRouter } from "vue-router";

const props = defineProps({
  svgName: {
    type: String,
    default: () => "exclamation",
  },
  content: {
    type: String,
    default: () => "用户反馈",
  },
  size: {
    type: String,
    default: () => "20px",
  },
  iconColor: {
    type: String,
    default: () => "#fff",
  },
  path: {
    type: String,
    default: () => "/",
  },
  type: {
    type: String,
    default: () => "",
  },
});

const $router = useRouter();

const handleClick = () => {
  if (props.type === "backTop") {
    document.body.scrollTop = document.documentElement.scrollTop = 0;
  } else {
    $router.push(props.path);
  }
};
</script>

<style scoped></style>
